import java.sql.Date;
import java.util.Iterator;
import java.util.List;

import play.*;
import play.jobs.*;
import play.test.*;

import models.*;


@Every("1s")
public class Bootstrap extends Job
{
	public void doJob()
	{
		List<Course> courses = Course.find("date_debut_course = NOW() order by date_debut_course desc").fetch();
		
		if(courses.size() > 0)
		{
			System.out.println("Il y a " + courses.size() + " course(s)");
			
			Iterator<Course> itor = courses.iterator();
			
			while(itor.hasNext())
			{
				System.out.println("La course " + courses.iterator().next().titre_course + " va etre traitee");
				Course c = itor.next();
				c.demarrerCourse();		
				c.modele.carte.genererMeteo();
			}
		}
	}
}
